import { BasicTable, useTable, BasicColumn, FormSchema } from "@/components/Table";
import { BasicForm, useForm } from "@/components/Form";
import { useState } from "react";
import { useDrawer } from "@/components/Drawer";
import CreareVaccinate from "./components/creareVaccinate";
import Toolbar from "@/components/ViewComponents/Toolbar";
import { useTranslation } from "react-i18next";
const UseHooks = () => {
	const { t } = useTranslation();
	const [data, setData] = useState([
		{
			dt_date: "555555555",
			patientId: "1",
			fullName: "Felix",
			birthday: "2024-01-05",
			age: "19",
			gender: "Men",
			noConsulted: "133554466",
			citizenId: "sanasn",
			noConsult: "gjdtrefawetyetgrshrsjsrsaddfgh",
			clinicName: "gjdtrefawetyetgrshrsjsrsaddfgh",
			houseNumber: "gjdtrefawetyetgrshrsjsrsaddfgh",
			street: "gjdtrefawetyetgrshrsjsrsaddfgh",
			Occupation: "gjdtrefawetyetgrshrsjsrsaddfgh",
			Province: "gjdtrefawetyetgrshrsjsrsaddfgh",
			District: "gjdtrefawetyetgrshrsjsrsaddfgh",
			commune: "gjdtrefawetyetgrshrsjsrsaddfgh",
			Ethnicity: "gjdtrefawetyetgrshrsjsrsaddfgh"
		}
	]);
	const dataApi = () => {
		return data;
	};
	const columnLeft: BasicColumn[] = [
		{
			title: t("felix_ui.patient_ID"),
			dataIndex: "patientId"
		},
		{
			title: t("felix_ui.no_consulted"),
			dataIndex: "noConsulted"
		},
		{
			title: t("felix_ui.no_consult"),
			dataIndex: "noConsult"
		},
		{
			title: t("felix_ui.citizen_id"),
			dataIndex: "citizenId"
		},
		{
			title: t("felix_ui.full_name"),
			dataIndex: "fullName"
		},
		{
			title: t("felix_ui.birthday"),
			dataIndex: "birthday"
		},
		{
			title: t("felix_ui.cli_name"),
			dataIndex: "clinicName"
		},
		{
			title: t("felix_ui.age"),
			dataIndex: "age"
		},
		{
			title: t("felix_ui.gender"),
			dataIndex: "gender"
		},
		{
			title: t("felix_ui.house_number"),
			dataIndex: "houseNumber"
		},
		{
			title: t("felix_ui.village_street"),
			dataIndex: "street"
		},
		{
			title: t("felix_ui.occupation"),
			dataIndex: "Occupation"
		},
		{
			title: t("felix_ui.province_city"),
			dataIndex: "Province"
		},
		{
			title: t("felix_ui.district"),
			dataIndex: "District"
		},
		{
			title: t("felix_ui.districtc_ward_commune"),
			dataIndex: "commune"
		},
		{
			title: t("felix_ui.ethnicity"),
			dataIndex: "Ethnicity"
		}
	];
	const columnTop: BasicColumn[] = [
		{
			title: t("felix_ui.totalDuration"),
			dataIndex: "totalDuration"
		},
		{
			title: t("felix_ui.averagePerCase"),
			dataIndex: "averagePerCase"
		},
		{
			title: t("felix_ui.averageExamination"),
			dataIndex: "averageExamination"
		},
		{
			title: t("felix_ui.averageTest"),
			dataIndex: "averageTest"
		},
		{
			title: t("felix_ui.averageImagingDiagnosis"),
			dataIndex: "averageImagingDiagnosis"
		}
	];
	const columnBottom: BasicColumn[] = [
		{
			title: t("felix_ui.code_numb"),
			dataIndex: "code_numb"
		},
		{
			title: t("felix_ui.drug_name"),
			dataIndex: "drug_name"
		},
		{
			title: t("felix_ui.unit_of_measure"),
			dataIndex: "unit_of_measure"
		},
		{
			title: t("felix_ui.activeIngredient"),
			dataIndex: "activeIngredient"
		},
		{
			title: t("felix_ui.quantity"),
			dataIndex: "quantity"
		}
	];
	const searchFormSchema: FormSchema[] = [
		{
			label: t("kevin_ui.patient_id"),
			field: "patientId",
			component: "Input"
		},
		{
			label: t("kevin_ui.full_name"),
			field: "fullName",
			component: "Input"
		},
		{
			label: t("kevin_ui.birth_year"),
			field: "birthday",
			component: "Input"
		},
		{
			label: t("felix_ui.age"),
			field: "age",
			component: "Input"
		},
		{
			label: t("felix_ui.gender"),
			field: "gender",
			component: "Input"
		}
	];
	const [register] = useForm({
		labelWidth: 120,
		schemas: searchFormSchema,
		showActionButtonGroup: true,
		showAdvancedButton: false,
		baseColProps: { span: 6 }
	});
	const [registerTableLeft, { reload }] = useTable({
		columns: columnLeft,
		dataSource: dataApi(),
		maxHeight: 500
	});
	const getTopList = () => {
		return [
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			},
			{
				totalDuration: "Felix",
				averagePerCase: "LENGEND",
				averageExamination: "2025-8-8",
				averageTest: "Renger",
				averageImagingDiagnosis: "DUDUDU···"
			}
		];
	};
	const getBottomList = () => {
		return [
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			},
			{
				code_numb: "LENGEND",
				drug_name: "Felix",
				unit_of_measure: "2025-8-8",
				activeIngredient: "Renger",
				quantity: "DUDUDU···"
			}
		];
	};
	const [registerTableTop] = useTable({
		columns: columnTop,
		dataSource: getTopList(),
		maxHeight: 230
	});
	const [registerTableBottom] = useTable({
		columns: columnBottom,
		dataSource: getBottomList(),
		maxHeight: 230
	});
	const [registerDrawer, { openDrawer: creata }] = useDrawer();
	/** Function */

	const addFn = (value: any) => {
		console.log(value);
		setData([...data, value]);
	};
	const handlerToolbarAction = (key: string) => {
		switch (key) {
			case "add":
				creata(true, {
					reload,
					addFn
				});
				break;
		}
	};
	/** Request */

	return (
		<div className="page">
			<div className="page-content h-100% flex flex-col">
				<div className="block">
					<BasicForm register={register}></BasicForm>
				</div>
				<div className="mt-2 flex flex-1">
					<div className="w-60% block">
						<BasicTable register={registerTableLeft}></BasicTable>
						<CreareVaccinate register={registerDrawer}></CreareVaccinate>
					</div>
					<div className="w-39% ml-2 h-100%">
						<div className="h-50% block">
							<BasicTable register={registerTableTop}></BasicTable>
						</div>
						<div className="h-49% mt-2 block">
							<BasicTable register={registerTableBottom}></BasicTable>
						</div>
					</div>
				</div>
			</div>
			<Toolbar action={handlerToolbarAction} btnList={[{ key: "add" }]} />
		</div>
	);
};

export default UseHooks;
